# A TOML linter such as https://taplo.tamasfe.dev/ can use this schema to validate your config.
# If you encounter any issues, please make an issue at https://github.com/yazi-rs/schemas.
# "$schema" = "https://yazi-rs.github.io/schemas/yazi.json"

[preview]
tab_size        = 22

[opener]
edit = [
	# { run = 'vim "$@"', desc = "$EDITOR", block = true, for = "unix" },
	{ run = 'wezterm start --always-new-process -e vim "$@"', orphan = true, desc = "$EDITOR", for = "unix" },
	{ run = 'code %*',    orphan = true, desc = "code",           for = "windows" },
	{ run = 'code -w %*', block = true,  desc = "code (block)",   for = "windows" },
]
open = [
	{ run = 'xdg-open "$1"',                desc = "Open", for = "linux" },
	{ run = 'open "$@"',                    desc = "Open", for = "macos" },
	{ run = 'start "" "%1"', orphan = true, desc = "Open", for = "windows" },
]
reveal = [
	{ run = 'xdg-open "$(dirname "$1")"',            desc = "Reveal", for = "linux" },
	{ run = 'open -R "$1"',                          desc = "Reveal", for = "macos" },
	{ run = 'explorer /select, "%1"', orphan = true, desc = "Reveal", for = "windows" },
	{ run = '''exiftool "$1"; echo "Press enter to exit"; read _''', block = true, desc = "Show EXIF", for = "unix" },
]
extract = [
	{ run = 'unar "$1"', desc = "Extract here", for = "unix" },
	{ run = 'unar "%1"', desc = "Extract here", for = "windows" },
]
play = [
	{ run = 'mpv --force-window "$@"', orphan = true, for = "unix" },
	{ run = 'mpv --force-window "%1"', orphan = true, for = "windows" },
	{ run = '''mediainfo "$1"; echo "Press enter to exit"; read _''', block = true, desc = "Show media info", for = "unix" },
]
show_font = [
	{ run = 'gnome-font-viewer "$1"', orphan = true, desc = "Show font", for = "linux" },
]
show_archive = [
	{ run = 'engrampa "$1"', orphan = true, desc = "Show archive", for = "linux" },
]

[open]
rules = [
	{ name = "*/", use = [ "edit", "open", "reveal" ] },

	{ mime = "text/*",          use = [ "edit", "reveal" ] },
	{ mime = "image/*",         use = [ "open", "reveal" ] },
  { mime = "{audio,video}/*", use = [ "open", "play", "reveal" ] },
	{ mime = "inode/x-empty",   use = [ "edit", "reveal" ] },

  { mime = "font/*",   use = [ "show_font", "open", "reveal" ] },
  { mime = "application/vnd.ms-opentype",   use = [ "show_font", "open", "reveal" ] },

	{ mime = "application/{,g}zip", use = [ "show_archive", "extract", "reveal" ] },
	{ mime = "application/x-{tar,bzip*,7z-compressed,xz,rar}", use = [ "show_archive", "extract", "reveal" ] },

	# { mime = "application/{,g}zip", use = [ "extract", "reveal" ] },
	# { mime = "application/x-{tar,bzip*,7z-compressed,xz,rar}", use = [ "extract", "reveal" ] },

	{ mime = "application/{json,x-ndjson}", use = [ "edit", "reveal" ] },
	{ mime = "*/javascript", use = [ "edit", "reveal" ] },

	{ name = "*", use = [ "open", "reveal" ] },
]

